import request from './request'
const userSer = '/?ser=user';
const companyJobSer = '/?ser=companyJob'
const transSer = '/?ser=transmission'
const deliverSer= '/?ser=deliver'

//登录
export function login(data){
  return request({
    url:'/user/login/?ser=user',
    method:'post',
    params:{
        userName:data.userName,
        password:data.password,
    }
  })
}

//退出登录
export function logout(){
  return request({
    url:'/user/logout'+userSer,
  })
}

//用户注销
export function logoutUser(password){
  return request({
    url:'/user/logoutUser'+userSer,
    method:'delete',
    params:{
      password
    },
  })
}

//获取个人信息
export function getPersonInfo(userName){
  return request({
    url:'/user/personInfo'+userSer,
    params:{
      userName
    },
  })
}



export function resumeInfo(resumeId){
  return request({
    url:'/resume/resumeInfo'+deliverSer,
    params:{
      resumeId
    },
  })
}
//修改个人信息
export function updatePersonInfo(infoForm){
  return request({
    url:'/user/updatePersonInfo'+userSer,
    method:'post',
    params:{
      userName:infoForm.userName,
      photoUrl: infoForm.photoUrl,
      pickName: infoForm.pickName,
      sex : infoForm.sex,
      age : infoForm.age,
      tel : infoForm.tel,
      email :infoForm.email,
      liveCity:infoForm.liveCity,
      position:infoForm.position,
      introduce:infoForm.introduce,
    },
  })
}

//获取职位列表
export function getJobList(keywords,currentPage,pageSize,companyName){
  return request({
    url:'/job/companyJob'+companyJobSer,
    params:{
      keywords,currentPage,pageSize,companyName
    },
  })
}
//上架下架职位
export function shelveJob(jobId){
  return request({
    url:'/job/shelveJob'+companyJobSer,
    method:'put',
    params:{
      jobId
    },
  })
}
//删除职位
export function delJob(jobId){
  return request({
    url:'/job/delJob'+companyJobSer,
    method:'put',
    params:{
      jobId
    },
  })
}

//密码修改
export function pwdChange(data){
  return request({
    url:'/user/pwdChange'+userSer,
    method:'put',
    params:{
      userName:localStorage.getItem("company_userName"),
      password:data.password,
      newPassword:data.newPassword,
    }
  })
}

export function sendCaptcha(tel){
  return request({
    url:'/captcha/message'+userSer,
    method:'put',
    params:{
      tel
    }
  })
}

export function reSetPwd(forget){
  return request({
    url:'/user/forgetPwd'+userSer,
    method:'put',
    params:{
      userName:forget.userName,
      newPassword:forget.newPassword,
      tel:forget.tel,
      captcha:forget.captcha
    }
  })
}

export function register(userName,password,tel,captcha){
  return request({
    url:'/user/register'+userSer,
    method:'put',
    params:{
      userName,password,tel,captcha
    }
  })
}

export function isRename(companyName){
  return request({
    url:'/company/register/companyIsLive'+companyJobSer,
    method:'put',
    params:{
      companyName
    }
  })
}

export function getCompanyInfo(companyName){
  return request({
    url:'/company/companyInfo'+companyJobSer,
    method:'put',
    params:{
      companyName
    }
  })
}

export function passResume(deliverId,state){
  return request({
    url:'/deliver/passDeliver'+deliverSer,
    method:'put',
    params:{
      deliverId,state
    }
  })
}

export function updateCompanyJob(infoForm){
  return request({
    url:'/job/updateJob'+companyJobSer,
    method:'put',
    params:{
      infoForm
    }
  })
}

export function addCompanyJob(infoForm){
  return request({
    url:'/job/addJob'+companyJobSer,
    method:'put',
    params:{
    infoForm
    }
  })
}
export function updateCompanyInfo(infoForm){
  return request({
    url:'/company/updateInfo'+companyJobSer,
    method:'put',
    params:{
      companyName:infoForm.companyName,
      logo:infoForm.logo,
      scale:infoForm.scale,
      tel: infoForm.tel,
      email: infoForm.email,
      address:infoForm.address,
      officialWebsiteUrl: infoForm.officialWebsiteUrl,
      financeList: infoForm.financeList,
      recruitUrl:infoForm.recruitUrl,
      legalPersonInfo:infoForm.legalPersonInfo,
      businessScope:infoForm.businessScope,
      companyInfo:infoForm.companyInfo
    }
  })
}
//获取用户列表
export function getUserList(userType,keywords,currentPage,pageSize,expect){
  return request({
    url:'/user/userList'+userSer,
    params:{
      userType,keywords,currentPage,pageSize,expect
    },
  })
}


//获取用户列表
export function getDeliverList(keywords,currentPage,pageSize,companyName,state){
  return request({
    url:'/deliver/deliverList'+deliverSer,
    params:{
      keywords,currentPage,pageSize,companyName,state
    },
  })
}

export function sendMessage(sendUserName,receiveUserName,content){
  return request({
    url:'/message/sendMessage'+userSer,
    params:{
      sendUserName,receiveUserName,content
    },
  })
}


//获取直播列表
export function getLiveList(keywords,currentPage,pageSize,companyName){
  return request({
    url:'/live/companyLive'+transSer,
    params:{
      keywords,currentPage,pageSize,companyName
    },
  })
}
//删除直播
export function delLive(liveId){
  return request({
    url:'/live/delLive'+transSer,
    method:'delete',
    params:{
      liveId
    },
  })
}



export function saveLive(form){
  return request({
    url:'/live/appointLive'+transSer,
    method:'post',
    params:{
      userName:form.userName,
      companyName:form.companyName,
      title:form.title,
      content:form.content,
      coverUrl:form.coverUrl,
      beginTime:form.beginTime,
      speaker:form.speaker
    },
  })
}
//获取视频列表
export function getVideoList(keywords,currentPage,pageSize,companyName){
  return request({
    url:'/video/companyVideoManage'+transSer,
    params:{
      keywords,currentPage,pageSize,companyName
    },
  })
}
//删除视频
export function delVideo(videoId){
  return request({
    url:'/video/delPreachVideo'+transSer,
    method:'delete',
    params:{
      videoId
    },
  })
}


export function uploadVid(companyName,userName,coverUrl,videoUrl,title,content,speaker){
  return request({
    url:'/video/upload'+transSer,
    method:'post',
    params:{
      companyName,userName,coverUrl,videoUrl,title,content,speaker
    },
  })
}

export function updateVideo(updateForm){
  return request({
    url:'/video/update'+transSer,
    method:'post',
    params:{
      videoId:updateForm.videoId,
      title:updateForm.title,
      content:updateForm.content,
      speaker:updateForm.speaker,
      coverUrl:updateForm.coverUrl,

    },
  })
}



export function updateLive(updateForm){
  return request({
    url:'/live/updateLive'+transSer,
    method:'post',
    params:{
      liveId:updateForm.liveId,
      title:updateForm.title,
      content:updateForm.content,
      speaker:updateForm.speaker,
      coverUrl:updateForm.coverUrl,
      beginTime:updateForm.beginTime
    },
  })
}